#!/usr/bin/env python
#coding:utf-8

import sys
import time
from PySide.QtCore import *
from PySide.QtGui import *

class mywindow(QWidget):
    def __init__(self):
        super(mywindow, self).__init__()
        self.initgui()

        self.btn1.clicked.connect(self.start1)
        self.btn2.clicked.connect(self.start2)

    def initgui(self):
        self.pgb1=QProgressBar()
        self.btn1=QPushButton('start')
        self.btn1.setSizePolicy(QSizePolicy.Fixed,QSizePolicy.Fixed)
        self.pgb2=QProgressBar()
        self.btn2=QPushButton('start')
        self.btn1.setSizePolicy(QSizePolicy.Fixed,QSizePolicy.Fixed)

        gl=QGridLayout()
        gl.addWidget(self.pgb1,0,0)
        gl.addWidget(self.btn1,0,1)
        gl.addWidget(self.pgb2,1,0)
        gl.addWidget(self.btn2,1,1)
        gl.setRowStretch(2,1)
        self.setLayout(gl)

        self.resize(300,100)

    def start1(self):
        self.pgb1.setMaximum=100
        self.pgb1.setMinimum=0
        for i in range(100):
            self.pgb1.setValue(i+1)
            QApplication.processEvents()
            time.sleep(0.05)

    def start2(self):
        self.pgb2.start()

def main():
    '''
    main function
    '''
    app = QApplication(sys.argv)
    window = mywindow()
    window.show()
    app.exec_()

if __name__ == '__main__':
    main()
